package com.zjs.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.zjs.common.Result;
import com.zjs.entity.User;
import com.zjs.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 关注公众号：MarkerHub
 * @since 2022-02-22
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;
    @RequiresAuthentication //需要身份验证
    @GetMapping()
    public Result getTeacher() {
        User user = userService.getById(1L);
        return Result.success(200, "操作成功", user);
    }
    //实体类数据校验
    @PostMapping("/save") //校验注解
    public Result save(@Validated @RequestBody User user) {
        return Result.success(user);
    }

}
